package com.crawler.execute;

import com.crawler.api.Crawlerscheduler;
import com.crawler.model.CrawlerRequestInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Arrays;

@Service
@Slf4j
public class DefaultCrawler {

    @Autowired
    private Crawlerscheduler crawlerscheduler;

    public  void addUrl(String... urls){
        Arrays.asList(urls).stream().forEach(e->
                {
                    CrawlerRequestInfo crawlerRequestInfo=new CrawlerRequestInfo();
                    crawlerRequestInfo.setMethod("GET");
                    crawlerRequestInfo.setUrl(e);
                    crawlerscheduler.push(crawlerRequestInfo);
                }

        );

    }



}
